<%@page import="dao.MngClass"%>
<%@page import="dao.CheckAccount"%>
<%@page import="beans.FeedBackBean"%>
<%@page import="java.util.List"%>
<%@page import="dao.FeedBackDAO"%>
<%@page import="dao.FAQ"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
        <style>                        
            table, th, td {
                border: 1px solid #619702;
                border-collapse: collapse;
                width:99.3% ;
            }
            th, td {
                padding: 5px;
                width: 100px;
            }
            th {
                text-align: center;
            }
        </style>
        <script language="javascript">
            function delete1()
            {
                return confirm('Do you want delete this record');
            }
        </script>
    </head>
    <body>
        <br><a href="student.jsp?page=createFB">Create new Feedback</a> <br>
        <h3>Your Feedback</h3>
        <%
            if (request.getAttribute("msg") != null) {
        %>
        <font color="green" > <%= request.getAttribute("msg")%> </font>
        <%
            }
             if (request.getAttribute("error") != null) {
        %>
        <font color="red" > <%= request.getAttribute("error")%> </font>
        <%
            }
        
            HttpSession ses = request.getSession();
            int acc_id = Integer.valueOf(ses.getAttribute("acc_id").toString());

            FeedBackDAO fbDAO = new FeedBackDAO();
            List<FeedBackBean> listFB = fbDAO.showFeedBackById(acc_id);
            CheckAccount ck = new CheckAccount();
            MngClass mngClass = new MngClass();
        %>
        <table>                
            <tr>                
                <th>Student</th>
                <th>Question</th>		
                <th>Answer</th>
                <th>Class</th>
            </tr> 
            <%  for (FeedBackBean FBBean : listFB) {
                    if (FBBean.getAnswer() == null) {
                        FBBean.setAnswer("");
                    }
            %>
            <tr>             
                <th><%= ck.getFullName(FBBean.getAcc_id())%></th>
                <th><%= FBBean.getQuestion()%></th>		
                <th><%= FBBean.getAnswer()%></th>
                <th><%= mngClass.getClassName(FBBean.getClass_id())%></th>
            </tr>   
            <%
                }
            %>
        </table>
    </body>
</html>
